﻿var bootPATH = __CreateJSPath("bi.js");

document.write('<script src="' + bootPATH + 'jquery/jquery.js" type="text/javascript"></script>');

// nui
document.write('<script src="' + bootPATH + 'nui/nui-min.js" type="text/javascript" ></script>');
document.write('<script src="' + bootPATH + 'nui/locale/zh_CN.js" type="text/javascript" ></script>');
document.write('<link href="' + bootPATH + 'nui/themes/default/miniui.css" rel="stylesheet" type="text/css" />');
document.write('<link href="' + bootPATH + 'nui/themes/default/nui-ext.css" rel="stylesheet" type="text/css" />');
document.write('<link href="' + bootPATH + 'nui/themes/icons.css" rel="stylesheet" type="text/css" />');
document.write('<link href="' + bootPATH + 'nui/themes/icons.css" rel="stylesheet" type="text/css" />');

// echarts
document.write('<script src="' + bootPATH + 'echarts/echarts.min.js" type="text/javascript"></script>');

// common
document.write('<script src="' + bootPATH + 'scripts/util.js" type="text/javascript" ></script>');
document.write('<script src="' + bootPATH + 'echarts/echarts.custom.js" type="text/javascript"></script>');
document.write('<link href="' + bootPATH + 'themes/default.css" rel="stylesheet" type="text/css" />');

var default_theme;
var theme = getQueryString('theme');
if (default_theme) theme = default_theme;

if (theme && theme != 'null') {
	document.write('<link href="' + bootPATH + 'themes/'+ theme +'/skin.css" rel="stylesheet" type="text/css" />');
}

function __CreateJSPath(js) {
    var scripts = document.getElementsByTagName("script");
    var path = "";
    for (var i = 0, l = scripts.length; i < l; i++) {
        var src = scripts[i].src;
        if (src.indexOf(js) != -1) {
            var ss = src.split(js);
            path = ss[0];
            break;
        }
    }
    var href = location.href;
    href = href.split("#")[0];
    href = href.split("?")[0];
    var ss = href.split("/");
    ss.length = ss.length - 1;
    href = ss.join("/");
    if (path.indexOf("https:") == -1 && path.indexOf("http:") == -1 && path.indexOf("file:") == -1 && path.indexOf("\/") != 0) {
        path = href + "/" + path;
    }
    return path;
}

function getQueryString(param){
	var reg = new RegExp("(^|&)"+ param +"=([^&]*)(&|$)");
	var r = window.location.search.substr(1).match(reg);
	if(r!=null)return unescape(r[2]);
	return null;
}
